package cn.stronglink.assetmanage.business.check.view.sync;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.stronglink.assetmanage.R;
import cn.stronglink.assetmanage.business.check.adapter.CheckListAdapter;
import cn.stronglink.assetmanage.entity.Check;
import cn.stronglink.assetmanage.utils.Constants;
import cn.stronglink.assetmanage.utils.ToastUtil;

import static cn.stronglink.assetmanage.R.color.f;

/**
 * 待同步数据
 * Created by chencongcong on 2018/6/14.
 */

public class CheckSyncView {
    private Fragment fragment;
    //表单列表
    @BindView(R.id.rv_checksync_order_list)
    RecyclerView rv_checksync_order_list;
    //表单列表adapter
    private CheckListAdapter listAdapter;

    public CheckSyncView(Fragment fragment, View view, CheckListAdapter listAdapter) {
        this.fragment = fragment;
        ButterKnife.bind(this, view);
        this.listAdapter = listAdapter;
    }


    public void setListData(final List<Check> listData) {
        if (listAdapter != null) {
            fragment.getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    listAdapter.notifyDatasChanged(listData);
                }
            });
        }
    }


    public void showSyncAssetFragment(String orderNo) {
        //跳转到详情页面
        Fragment syncAssetFragment = new SyncAssetFragment();
        FragmentManager fragmentManager = fragment.getActivity().getSupportFragmentManager();
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        transaction.replace(R.id.frame_business, syncAssetFragment);
        transaction.commit();
        Bundle bundle = new Bundle();
        bundle.putString(Constants.CHECK_IN_DETAIL_NO, orderNo);
        syncAssetFragment.setArguments(bundle);
    }

    public void showProgressDialog(String msg) {

    }

    public void hideProgressDialog() {

    }

    public void showToast(String msg) {
        ToastUtil.toastShort(msg);
    }
}
